 |
 |
 |
 |
 |
 |
 |
|
|
 |
Logical
connectors
|
Some
remarks
|
|
|
|
|
|
 |
 |
 |
 |
 |
• |
It is perfectly
legal in C++ to use boolean operators on
|
|
variables which
are not booleans. In C++, "0" is false and
|
any non-zero
value is true. Let's look at a contrived
|
|
example.
|
|
|
|
|
|
 |
 |
 |
int hours = 4;
|
|
int minutes =
21;
|
|
int seconds = 0;
|
|
|
bool timeIsTrue
= hours && minutes && seconds;
|
|
|
|
|
 |
 |
 |
NOTE: Since hours evaluates to true, and since minutes
|
|
evaluates to true, and since seconds evaluates to false, the
|
entire
expression hours
&& minutes && seconds evaluates
|
|
to false.
|
|
|
|
|